<template>
  <div class="box">
    <van-nav-bar
      left-arrow
      @click-left='$router.go(-1)'
      title="评论"
      :border="false"
      fixed
    />
    <section>
      <div class="b">
        <van-tabs v-model="activeName" :animated='true' line-height='1'>
          <van-tab title="通知" name="a">
            <div v-if="messageList.length">
              <div class="commentList_box" v-for="(item, index) in messageList" :key="index" @click="goMessageDetail(item.message_id)">
                <div class="commentList_box_pic">
                  <img :src="item.message_uservia" alt="">
                </div>
                <div class="commentList_box_text">
                  <p>
                    <span>{{item.message_nickname}}</span>
                    <span>{{item.message_timer}}</span>
                  </p>
                  <p>{{item.message_type}}</p>
                  <p>{{item.notice_content}}</p>
                </div>
              </div>
            </div>
            <div v-else class="noData">
              <img src="../../assets/liwudi.png" alt="">
              <span>您还没有相关的评论~</span>
            </div>
          </van-tab>
          <van-tab title="日记" name="b">
            <div v-if="diaryList.length">
              <div class="commentList_box" v-for="(item, index) in diaryList" :key="index" @click="goDiaryDetail(item.diary_id)">
                <div class="commentList_box_pic">
                  <img :src="item.diary_issue_via" alt="">
                </div>
                <div class="commentList_box_text">
                  <p>
                    <span>{{item.diary_issue_nickname}}</span>
                    <span>{{item.diary_issue_time}}</span>
                  </p>
                  <p>{{item.diary_kind}}</p>
                  <p>{{item.diary_comment_content}}</p>
                </div>
              </div>
            </div>
            <div v-else class="noData">
              <img src="../../assets/liwudi.png" alt="">
              <span>您还没有相关的评论~</span>
            </div>
          </van-tab>
        </van-tabs>
      </div>
    </section>
  </div>
</template>

<script>
import Vue from 'vue'
import { NavBar, Tabs, Tab } from 'vant'
import { getComment } from '@/api'
Vue.use(NavBar)
Vue.use(Tabs)
Vue.use(Tab)
export default {
  data () {
    return {
      activeName: 'a',
      diaryList: [],
      messageList: [],
      username: ''
    }
  },
  mounted () {
    this.username = localStorage.getItem('userTel_AM')
    getComment({ type: '通知', username: this.username }).then(res => {
      if (res.data.code === '200') {
        this.messageList = res.data.data
      }
    })
    getComment({ type: '日记', username: this.username }).then(res => {
      if (res.data.code === '200') {
        this.diaryList = res.data.data
      }
    })
  },
  methods: {
    goMessageDetail (messageId) {
      this.$router.push('/inform/informDetail?message_id=' + messageId)
    },
    goDiaryDetail (diaryId) {
      this.$router.push({ path: '/Redetail/' + 'diary_id=' + diaryId })
    }
  }
}
</script>

<style lang="scss" scoped>
.noData {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 1.5rem;
  flex-direction: column;
  img {
    height: 1rem;
    width: 1rem;
  }
}
section {
  width: 100%;
  height: auto;
  margin-top: 0.46rem;
  .commentList_box {
    width: 100%;
    min-height: 1.14rem;
    /* height: auto; */
    padding: 0.19rem;
    .commentList_box_pic {
      width: 0.46rem;
      height: 100%;
      float: left;
      margin-right: 0.11rem;
      img {
        width: 0.46rem;
        height: 0.46rem;
      }
    }
    .commentList_box_text {
      width: 2.8rem;
      /* min-height: 0.95rem; */
      height: auto;
      float: left;
      border-bottom: 1px solid #ececec;
      p:nth-of-type(1) {
        width: 100%;
        height: 0.24rem;
        line-height: 0.24rem;
        span:nth-of-type(1) {
          max-width: 200px;
          float: left;
          color: #4a4a4a;
          font-size: 0.14rem;
        }
        span:nth-of-type(2) {
          max-width: 200px;
          float: right;
          color: #cdcdcd;
          font-size: 0.1rem;
        }
      }
      p:nth-of-type(2) {
        width: 100%;
        height: 0.2rem;
        line-height: 0.2rem;
        font-size: 0.12rem;
        color: #c0c0c0;
        margin-bottom: 0.12rem;
      }
      p:nth-of-type(3) {
        width: 100%;
        height: auto;
        line-height: 0.14rem;
        font-size: 0.12rem;
        color: #5c5c5c;
        word-wrap: break-word;
        margin-bottom: 0.07rem;
      }
    }
  }
}
/deep/ .van-nav-bar {
  z-index: 100;
}
/deep/ .van-icon-arrow-left {
  font-size: 0.22rem;
  color: #171717;
}
/deep/ .van-nav-bar__title {
  font-size: 0.18rem;
  color: #171717;
  font-weight: bold;
}
</style>
